package cn.stylefeng.guns.modular.business.frequency.financesettlement.mapper;

import cn.stylefeng.guns.modular.business.frequency.finance.model.param.SettlementVO;
import cn.stylefeng.guns.modular.business.frequency.finance.model.result.PkgFinanceSettlement;
import cn.stylefeng.guns.modular.business.frequency.financesettlement.model.param.FinanceSettlementDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.stylefeng.guns.modular.business.frequency.financesettlement.entity.FinanceSettlement;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 订单财务结算表（日记账） Mapper 接口
 *
 * @author yujie
 * @date 2023/05/09 17:17
 */
public interface FinanceSettlementMapper extends BaseMapper<FinanceSettlement> {

    Page<PkgFinanceSettlement> getListBySettlementVO(@Param("page") Page page,@Param("settlementVO") SettlementVO settlementVO,@Param("tenantId") Long tenantId);

    @Update("update tt_finance_settlement set status = #{status} where id = #{id}")
    void updateStatusById(@Param("id") Long id, @Param("status") Integer status);


    @Update("update tt_finance_settlement set result = #{result} where id = #{id}")
    void updateResultById(@Param("id") Long id, @Param("result") Integer result);

    FinanceSettlement getByOrderIdAndTypeAndCheckId(@Param("orderId") Long orderId, @Param("type") Integer type,
                                                    @Param("checkId") Long checkId);

    FinanceSettlement getByOrderIdAndTransportId(@Param("orderId") Long orderId, @Param("transportId") Long transportId, @Param("checkId") Long checkId);

    FinanceSettlement getByOrderIdAndOrderExtraFeeId(@Param("orderId") Long orderId, @Param("orderExtraFeeId") Long orderExtraFeeId, @Param("checkId") Long checkId);

    Page<PkgFinanceSettlement> getFinanceSettlementList(@Param("page") Page page, @Param("financeSettlementDTO") FinanceSettlementDTO financeSettlementDTO,@Param("tenantId") Long tenantId);

    PkgFinanceSettlement getFinanceSettlementSummary(@Param("financeSettlementDTO") FinanceSettlementDTO financeSettlementDTO,@Param("tenantId")Long tenantId);

    PkgFinanceSettlement getFinanceSettlementDetail(@Param("id") String id);

    int countByOrderId(@Param("orderId") String orderId);
}